package com.oglvip.business.remote.service.resolvers;

import org.springframework.beans.factory.FactoryBean;

/**
 * service的工厂类，通过该类将service交由spring管理
 * @auther hanchao
 * @date 2016/12/22 10:59
 */
public class ServiceFactoryBean implements FactoryBean {
    private Class<?> targetClass;
    private Object targetBean;
    private boolean singleton = true;

    public void setSingleton(boolean singleton) {
        this.singleton = singleton;
    }

    public void setTargetClass(Class<?> targetClass) {
        this.targetClass = targetClass;
    }

    public void setTargetBean(Object targetBean) {
        this.targetBean = targetBean;
    }


    @Override
    public Object getObject() throws Exception {
        return targetBean;
    }

    @Override
    public Class<?> getObjectType() {
        return targetClass;
    }

    @Override
    public boolean isSingleton() {
        return singleton;
    }
}
